<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>用户登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--[if lt IE 9]>
        <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
        <script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
    <!-- jquery -->
    <script src="public/js/jquery-2.0.3.min.js"></script>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="public/css/bootstrap.min.css">
    <script src="public/js/bootstrap.min.js"></script>
    <script type="text/javascript">
    	function login(){
    		if($("#nameError").val() == ''){
    			$("#userDiv").removeClass("has-success");
    			$("#userDiv").addClass("has-error");
    			return;
    		}else{
    			$("#userDiv").removeClass("has-error");
    			$("#userDiv").addClass("has-success");
    		}
    		if($("#pwdError").val() == ''){
    			$("#pwdDiv").removeClass("has-success");
    			$("#pwdDiv").addClass("has-error");
    			return;
    		}else{
    			$("#pwdDiv").removeClass("has-error");
    			$("#pwdDiv").addClass("has-success");
    		}
    		$("#loginForm").attr("action","login");
    		$("#loginForm").submit();
    	}
    </script>
  </head>
  
  <body>
  		<div class="alert alert-warning alert-danger">
			<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
			<strong>Error!</strong><s:fielderror/>
		</div>
	<div class="container" style="width: 300px;margin-top: 100px;">
		
		
      <form id="loginForm" method="post">
        <h2>请登录</h2>
        <div id="userDiv" class="form-group">
			<label class="control-label" for="inputError">用户名不能为空！</label>
	        <input name="user.name" type="text" class="form-control" id="nameError" placeholder="用户名" autofocus>
		</div>
		<div id="pwdDiv" class="form-group">
			<label class="control-label" for="pwdError">密码不能为空！</label>
	        <input name="user.password" type="password" class="form-control" id="pwdError" placeholder="密码">
        </div>
        <label class="checkbox">
          <input type="checkbox" value="remember-me"> 记住我
        </label>
        <button class="btn btn-lg btn-primary btn-block" type="button" onclick="login();">登录</button>
      </form>

    </div>
  </body>
</html>
